﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace FirstGame
{
    public class CheckItem : MenuItem
    {
        private bool _IsChecked = false;

        public bool IsChecked
        {
            get { return _IsChecked; }
            set { _IsChecked = value; }
        }
        public CheckItem(ContentManager content, MenuScreen parent, string strTexture1, string strTexture2, Vector2 topleft, Vector2 inittopleft, Vector2 size)
        {
            TopLeft = topleft;
            Size = size;
            Menuscreen = parent;
            _InitTopleft = inittopleft;
            _CurrentTopleft = _InitTopleft;
            
            Texture2D[] textures1 = new Texture2D[1];
            textures1[0] = content.Load<Texture2D>(strTexture1);

            Texture2D[] textures2 = new Texture2D[1];
            textures2[0] = content.Load<Texture2D>(strTexture2);

            Sprites = new List<My2Dsprite>();
            My2Dsprite Sprite1 = new My2Dsprite(textures1, topleft);
            My2Dsprite Sprite2 = new My2Dsprite(textures2, topleft);

            Sprites.Add(Sprite1);
            Sprites.Add(Sprite2);

            NSprite = Sprites.Count;            
        }

        public override void Update(GameTime gameTime, InputSystem input)
        {
            if (_Menuscreen.ScreenState == ScreenState.Active)
            {
                if (this.IsClicked(input.CurPoint) && input.IsNewMouseClick(ButtonState.Pressed))
                {
                    if (!IsChecked)
                    {
                        IsChecked = true;
                        this.Select();
                    }
                    else
                        IsChecked = false;
                }

                base.Update(gameTime, input);
            }
        }

        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            if(IsChecked)
                Sprites[1].Draw(gameTime, spriteBatch, 255);
            else
                Sprites[0].Draw(gameTime, spriteBatch, 255);
        }
    }
}
